<template>
    <h3 style="text-align: center;">
        管理员-理财列表
    </h3>
    理财编号：
    <input type="text" v-model="Search.F_Fid" />
    理财名称：
    <input type="text" v-model="Search.F_Fname" />
    <button @click="Shows">查询</button>
    <table class="table table-bordered" border="1">
        <!-- 理财ID、理财名称、年收益、利息、最低金额、理财人次、风险等级 -->
       <thead>
        <tr>
            <td> 理财ID</td>
            <td> 理财名称</td>
            <td> 年收益</td>
            <td> 利息</td>
            <td> 最低金额</td>
            <td> 理财人次</td>
            <td> 风险等级</td>
            <td>操作</td>
        </tr>
       </thead>
       <tbody>
        <tr v-for="item in Info" :key="item.F_Fid">
            <td>{{item.F_Fid}}</td>
            <td>{{item.F_Fname}}</td>
            <td>{{item.F_FAPY}}</td>
            <td>{{item.F_ULeach}}</td>
            <td>{{item.F_FMinmoney}}</td>
            <td>{{item.F_Fnumber}}</td>
            <td>{{item.F_FFxdj}}</td>
            <td>
                <a href="#" @click="Delete(item.F_Fid)">删除</a>
            </td>
        </tr>
       </tbody>
    </table>
    <div>
        共计{{Fenye.listCount}}条数据
        每页{{Fenye.pageSize}}条
        当前为{{Fenye.pageIndex}}/{{Fenye.pageCount}}页
        <a href="#" @click="Tiaoz('A')" >首页</a>
        <a href="#" @click="Tiaoz('B')">上一页</a>
        <a href="#" @click="Tiaoz('C')">下一页</a>
        <a href="#" @click="Tiaoz('D')" >尾页</a>
        <input type="text" v-model="Fenye.Gouye" style="width: 30px;">
        <button  @click="GOtoy">跳转</button>
    </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const Info=ref([{
    F_Fid:0,
    F_Fname:'',
    F_FAPY:'',
    F_Uid:0,
    F_FMinmoney:'',
    F_Fnumber:'',
    F_FFxdj:'',
    F_ULeach:'',
}])
//分页条件
const Fenye = ref({
  pageIndex:1,
  pageSize:2,
  listCount:0,
  pageCount:0,
  Gouye:1,
    
})
//查询条件
const Search = ref({
    F_Fid:0,
    F_Fname:'',
})
//分页方法
function Tiaoz(Try:string){
    switch(Try){
        case 'A':
            Fenye.value.pageIndex=1;
            break;
        case 'B':
            if(Fenye.value.pageIndex>1){
                Fenye.value.pageIndex--;
            }
            break;
        case 'C':
            if(Fenye.value.pageIndex<Fenye.value.pageCount)
            {
                Fenye.value.pageIndex++;
            }
            break;
        case 'D':
            Fenye.value.pageIndex=Fenye.value.pageCount;
            break;
   
    }
    Shows();
}
///跳转指定页
function GOtoy(){
    Fenye.value.pageIndex=Fenye.value.Gouye;
    Shows();
}
import axios from 'axios';

//钩子
import { onMounted } from 'vue';
onMounted(() => {
  Shows();  
})
//显示
function Shows(){
    axios.get('https://localhost:44369/api/Financs/ShowPeopleGL',
    {
        params:{
            F_Fid:Search.value.F_Fid,
            F_Fname:Search.value.F_Fname,
            pageIndex:Fenye.value.pageIndex,
            pageSize:Fenye.value.pageSize,
        }
    }
    )
    .then((res)=>{
        Info.value=res.data.list;
        Fenye.value.listCount=res.data.listCount;
        Fenye.value.pageCount=res.data.pageCount;
    })
    .catch((err)=>{
        console.log(err)    
    })
}
///删除
const Delete=(F_Fid:number)=>{
    if(confirm("是否删除"))
    {
        axios.get('https://localhost:44369/api/Financs/Delete',
    {
        params:{
            F_Fid:F_Fid,
        }
    }
    )
    .then((res)=>{
        if(res.data>0){
            alert("删除成功");
            Shows();
        }
        else{
            alert("删除失败");
        }
    })
    .catch((err)=>{
        console.log(err)    
    })
    }
    
}

</script>